<?php
/*
*All rights reserved: Json.
*Links:http://www.liyaoquan.cn.
*Links:http://imarkchina.cn.
*Links:http://www.imarkchina.cn.
*/

/**
 * 博客后台数据操作控制器，负责，业务流程判断
 * 后台所有操作都需要权限，必需继承 CommonAction 控制器
 */
Class GetbackupAction extends CommonAction{

	/**
	 * 数据备份显示
	 * @return [type] [description]
	 */
	Public function index(){
		$this->display();
	}

	/**
	 * 数据还原显示
	 * @return [type] [description]
	 */
	Public function reback(){
		$this->display();
	}

	/**
	 * 检查更新显示
	 * @return [type] [description]
	 */
	Public function checkupdata(){
		$this->display();
	}

	/**数据备份操作
	 * [backupall description]
	 * @return [type] [description]
	 */
	Public function backupall(){
		if (M('Getbackup')->BackUPAll()) {
			$this->success('备份成功～！', U('index'));
		} else {
			$this->error('备份失败～！');
		}
	}

	/**
	 * 数据还原操作
	 * @return [type] [description]
	 */
	Public function replayall(){
		if (M('Getbackup')->RePlayAll()) {
			$this->success('还原成功～！', U('reback'));
		} else {
			$this->error('还原失败～！请检查根目录是否存在压缩包～！');
		}
	}

	/**
	 * 检查更新
	 * @return [type] [description]
	 */
	Public function check(){
		$M = M('Getbackup')->Check();
		if (!$M) {
			$this->error('暂无更新～！');
		}
		$this->assign('check', $M);
		$this->display();
	}

	/**
	 * 博客升级
	 * @return [type] [description]
	 */
	Public function upgrade(){
		if (ISPOST) {
			if (M('Getbackup')->UPGrade()) {
				$this->success('升级成功～！', U('index/index'));
			} else {
				$this->error('升级失败～！');
			}
		}
		P(session('upgrade'));
	}
}